//
//  RepeatedModel.swift
//  photoTool
//
//  Created by Galaxy on 2023/11/9.
//

import Foundation
@preconcurrency import WCDBSwift
/*
import RealmSwift

class RepeatedModel : Object {
    
    @Persisted var id:String = UUID.init().uuidString
    // 图片1
    @Persisted var leftImgId:String = ""
    // 图片2
    @Persisted var rightImgId:String = ""
    // 差值
    @Persisted var value:Float = 0.0
}
*/

final class RepeatedModel: TableCodable {
    var identifier: Int? = nil
    var leftImgId: String? = nil
    var rightImgId: String? = nil
    var value: Float? = nil
    // 用于获取自增插入后的主键值
    var lastInsertedRowID: Int64 = 0
    // 自增
    var isAutoIncrement: Bool { true }
    enum CodingKeys: String, CodingTableKey {
        typealias Root = RepeatedModel
        static let objectRelationalMapping = TableBinding(CodingKeys.self) {
            // 设置属性为自增
            BindColumnConstraint(identifier, isPrimary: true)
            // 给字段设置默认值，设置是否为空
            BindColumnConstraint(leftImgId, isNotNull: true, defaultTo: "")
            BindColumnConstraint(rightImgId, isNotNull: true, defaultTo: "")
            BindColumnConstraint(value, isNotNull: true, defaultTo: 0.0)
        }
        case identifier
        case leftImgId
        case rightImgId
        case value
    }
}


